﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace zjbks
{
    public partial class DaoRuRuQuJieGuo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            // 指定保存位置
            string savepath = System.Web.HttpContext.Current.Server.MapPath("./files/");
            if (FileUpload1.HasFile)
            {
                string filename = FileUpload1.FileName;
                savepath += filename;
                FileUpload1.SaveAs(savepath);
                try
                {
                    ExcelToMSSql.DataTranfluqu(savepath);
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('导入成功')</script>");
                    GridView1.DataBind();
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('导入失败')</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('请选择文件')</script>");
            }
        }
    }
}